﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="permission.aspx.cs" Inherits="WebUI.library.permission" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <table align="center">
        <tr>
            <td align="center">
                Users
            </td>
        </tr>
        <tr>
            <td align="center">
                <asp:GridView ID="gvUser" runat="server" AutoGenerateColumns="False" ShowFooter="True"
                    OnRowUpdating="gvUser_RowUpdating" OnRowDataBound="gvUser_RowDataBound" 
                    onrowcommand="gvUser_RowCommand" onrowdeleting="gvUser_RowDeleting" 
                    DataKeyNames="UserID" onrowediting="gvUser_RowEditing" 
                    onrowcancelingedit="gvUser_RowCancelingEdit">
                    <Columns>
                        <asp:TemplateField HeaderText="User Name">
                            <EditItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text=''></asp:Label>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:DropDownList ID="drpUser" runat="server" ValidationGroup="addUserPermission">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="drpUser"
                                    ErrorMessage="*" ValidationGroup="addUserPermission">*</asp:RequiredFieldValidator>
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("UserID") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Mask">
                            <EditItemTemplate>
                                <asp:DropDownList ID="drpMask" runat="server" ValidationGroup="addUserPermissionEdit">
                                <asp:ListItem Text="Permit" Value="1" />
                                <asp:ListItem Text="Deny" Value="2" />
                               </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="drpMask"
                                    ErrorMessage="*" ValidationGroup="addUserPermissionEdit">*</asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:DropDownList ID="drpMask" runat="server" ValidationGroup="addUserPermission">
                                <asp:ListItem Text="Permit" Value="1" />
                                <asp:ListItem Text="Deny" Value="2" />
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="drpMask"
                                    ErrorMessage="*" ValidationGroup="addUserPermission">*</asp:RequiredFieldValidator>
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("PermissionMask") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField InsertVisible="False" ShowHeader="False">
                            <EditItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                    Text="Update" ValidationGroup="addUserPermissionEdit"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                    Text="Cancel"></asp:LinkButton>
                            </EditItemTemplate>
                            <FooterTemplate>
                                <asp:LinkButton ID="addUserPermission" runat="server" ValidationGroup="addUserPermission" CommandName="add">Add User Permission</asp:LinkButton>
                            </FooterTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                    Text="Edit"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        No Permission is Given to users
                    </EmptyDataTemplate>
                </asp:GridView>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
